package cn.st4rlight.util.exception;

/**
 * 系统异常
 *
 * @author st4rlight <st4rlight@163.com>
 * Created on 2024-04-14
 */
public class ServiceException extends RuntimeException {

    protected ServiceException(String message) {
        super(message);
    }

    protected ServiceException(Throwable cause) {
        super(cause);
    }

    public ServiceException(String errMsg, Throwable cause) {
        super(errMsg, cause);
    }


    public static ServiceException of(String errMsg) {
        return new ServiceException(errMsg);
    }

    public static ServiceException of(Throwable cause) {
        return new ServiceException(cause);
    }

    public static ServiceException of(String errMsg, Throwable cause) {
        return new ServiceException(errMsg, cause);
    }

    public static void assertTrue(boolean flag, String errMsg) {
        if (!flag) {
            throw ServiceException.of(errMsg);
        }
    }
}
